/*工程后台*/
'use strict';
const engineeringAddAction = require('../actions/engineering/engineeringAddAction');
const engineeringUpdateAction = require('../actions/engineering/engineeringUpdateAction');
const engineeringDelAction = require('../actions/engineering/engineeringDelAction');
const engineeringListQueryAction = require('../actions/engineering/engineeringListQueryAction');
const engineeringQueryAction = require('../actions/engineering/engineeringQueryAction');
const engineeringCloneAction = require('../actions/engineering/engineeringCloneAction');

module.exports = async function (ctx) {
    let param = ctx.method === 'GET' ? ctx.query : ctx.request.fields;
    let action_type = param.action_type;
    try {
        switch (action_type) {
            case 'engineeringAdd': // 工程添加
                ctx.body = await engineeringAddAction(param);
                break;
            case 'engineeringUpdate': // 工程修改
                ctx.body = await engineeringUpdateAction(param);
                break;
            case 'engineeringDel': // 工程删除
                ctx.body = await engineeringDelAction(param);
                break;
            case 'engineeringListQuery': // 工程列表查询
                param.user_id = ctx.session.user.user_id;
                param.is_manager = ctx.session.user.is_manager;
                ctx.body = await engineeringListQueryAction(param);
                break;
            case 'engineeringQuery': // 工程查询
                ctx.body = await engineeringQueryAction(param);
                break;
            case 'engineeringClone': // 工程克隆
                ctx.body = await engineeringCloneAction(param);
                break;
        }
    } catch (e) {
        ctx.body = {success: false, message: e.message};
    }

};